﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using BusinnessLogic;
using DataLayer;
using Model;

namespace scrumbench
{
    public partial class NewSprint : Form
    {
        public NewSprint()
        {
            InitializeComponent();
        }

        public NewSprint(int product, string productname)
        {
            InitializeComponent();
            productid = product;
            this.productname = productname;

        }

        private string productname;

        public string Productname
        {
            get { return productname; }
            set { productname = value; }
        }


        private string titel;

        public string Titel
        {
            get { return titel; }
            set { titel = value; }
        }

        private string description;

        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        private DateTime begin;

        public DateTime Begin
        {
            get { return begin; }
            set { begin = value; }
        }

        private DateTime end;

        public DateTime End
        {
            get { return end; }
            set { end = value; }
        }

        private int teamid;

        public int Teamid
        {
            get { return teamid; }
            set { teamid = value; }
        }

        private int productid;

        public int Productid
        {
            get { return productid; }
            set { productid = value; }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            titel = textBox1.Text;
            description = textBox2.Text;
            begin = monthCalendar1.SelectionStart;
            end = monthCalendar1.SelectionEnd;

            InsertProduct iprod = new InsertProduct();
            iprod.Insertsprint(titel, description, begin, end, productid, teamid);
        }

        private void NewSprint_Load(object sender, EventArgs e)
        {
           label5.Text = "Add a new Sprint to Product: " + productname;
            
            PopulateTeamTreeView mijntreeview = new PopulateTeamTreeView();
            List<Team> allteams = new List<Team>();
            allteams = mijntreeview.PopulateTeamlist();

            foreach (Team mijnteam in allteams)
            {
                comboBox1.Items.Add(mijnteam);
            }

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string team = comboBox1.Text;

            PopulateTeamTreeView mijntreeview = new PopulateTeamTreeView();
            List<Team> allteams = new List<Team>();
            allteams = mijntreeview.PopulateTeamlist();

            foreach (Team mijnteam in allteams)
            {
                if (team == mijnteam.name)
                {
                    teamid = mijnteam.teamID;
                    break;
                }
            }
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

    }
}
